<?php echo $this->render($this->includeDir . '/toolbar.php');?>
<?php echo $this->flashMessage();?>
<?php 
	$arrParam = $this->arrParam;
	$arrFilter 	= $this->arrParam['arrFilter'];
	$value = 'http://www.zend.vn';
	
	/*===============================================
	 * Start - Tạo các phần tử cho Form
	 *===============================================*/	
	
	
	$name 		= $this->formText('name',$this->Item['name'],array('class'=>'width-300 bg-green2 floatLeft' ));
	$alias 		= $this->formText('alias',$this->Item['alias'],array('class'=>'width-300 floatLeft' ));
	$menu_group_id 		= $this->formHidden('menu_group_id','admin');
	

	
	$slbGroup 	= array(); 
	$parents	= $this->formSelect('parents',$parents,array('class'=>'width-150'),$slbGroup);	
	$ordering	= $this->formText('ordering',$this->Item['ordering'],array('class'=>'width-100 floatLeft'));
	
	$parents	= $this->cmsSelect('parents', $this->Item['parents'],array('class'=>'width-250','size'=>10), $this->slbParents);
	
	//$slbLang	= $this->formSelect('language_code',$parents,array('class'=>'width-150'),$this->slbLang);	
	
	$options 	= array('root'=>$this->translate('Root'),
						'module'=>$this->translate('Module'),
						'link'=>$this->translate('Link'),
					);	
	$type		= $this->formSelect('mtype',$this->Item['mtype'],array('class'=>'width-150','onChange'=>'menuType(this.value);'),$options, ' ');
	
	$url 		= $this->formText('url',$this->Item['url'],array('class'=>'width-300 floatLeft'));
	$module 	= $this->formText('m_module',$this->Item['m_module'],array('class'=>'width-200 bg-green2 floatLeft'));
	$controller	= $this->formText('m_controller',$this->Item['m_controller'],array('class'=>'width-200 bg-green2 floatLeft'));
	$action		= $this->formText('m_action',$this->Item['m_action'],array('class'=>'width-200 bg-green2 floatLeft'));
	$params		= $this->formTextarea('m_params',Zendvn_Filter_Filter::filterContent($this->Item['m_params'],'filter'),
									   array('class'=>'width-400 floatLeft','rows'=>6));
	
	$options 	= array('inactive'=>$this->translate('Inactive'),'active'=>$this->translate('Active'));		
	$status 	= $this->formSelect('status',$this->Item['status'],array('class'=>'width-150'),$options);
	
	$router		= $this->formText('router',$this->Item['router'],array('class'=>'width-100 floatLeft'));
	
	/*=======================================================
	 * Start - Tạo Tooltip cho các phần từ input trong form
	 *=======================================================*/	
	$formHelp = '';
	$formHelp  .= $this->cmsFormHelp('.form-table #name', $this->translate("Name of menu.|Ex: Admin menu, Home menu..."));
	$formHelp  .= $this->cmsFormHelp('.form-table #alias', $this->translate("Alias of menu."));
	$formHelp  .= $this->cmsFormHelp('.form-table #parents', $this->translate("Parents of menu."));
	$formHelp  .= $this->cmsFormHelp('.form-table #mtype', $this->translate("Type of menu."));
	$formHelp  .= $this->cmsFormHelp('.form-table #router', $this->translate('Router name of menu'));
	$formHelp  .= $this->cmsFormHelp('.form-table #status', $this->translate("Status of menu group"));	
	
	/*=======================================================
	 * Start - Hiển thị các thông báo error của Form 
	 *=======================================================*/	
	
	 if(count($this->errors)>0){	
	 	foreach ($this->errors as $key => $val){	 		
	 		$$key .= $this->cmsError($key,$val);	
	 		$selector = '.form-table #' . $key . '-error';
	 		$options = array('type'=>'error','name'=>'#' .$key);
	 		$formHelp  .= $this->cmsFormHelp($selector, $this->translate($val),null,$options);
	 		
	 	}
	 }
	
	/*=======================================================
	 * Start - Hiển thị các thông báo error của Form 
	 *=======================================================*/	
	 $arrRow = array(
						array('label'=>$this->translate('Name'),'input'=>$name.$menu_group_id),						
						array('label'=>$this->translate('Alias'),'input'=>$alias),
						
						array('label'=>$this->translate('Parents'),'input'=>$parents,
							  'tdStyle'=>array('id'=>'tdParents')),		
						array('label'=>$this->translate('Type'),'input'=>$type),
						array('label'=>$this->translate('Url'),'input'=>$url,
							  'trStyle'=>array('style'=>'display: none;','id'=>'trUrl')),				
						array('label'=>$this->translate('Module'),'input'=>$module,
							  'trStyle'=>array('style'=>'display: none;','id'=>'trModule')),				
						array('label'=>$this->translate('Controller'),'input'=>$controller,
							   'trStyle'=>array('style'=>'display: none;','id'=>'trController')),
						array('label'=>$this->translate('Action'),'input'=>$action,
								'trStyle'=>array('style'=>'display: none;','id'=>'trAction')),	
						array('label'=>$this->translate('Params'),'input'=>$params,
								'trStyle'=>array('style'=>'display: none;','id'=>'trParam')),						
						array('label'=>$this->translate('Status'),'input'=>$status),						
						array('label'=>$this->translate('Router name'),'input'=>$router),	
					 );
	$tdForm = $this->partialLoop('row-menu.php',$arrRow);
	
	$ajaxLink =  $this->url(array('action'=>'ajax','type'=>'parents'));
	$loadModule =  $this->url(array('action'=>'ajax-module'));

?>

<script type="text/javascript">
	$(document).ready(function() {
		<?php echo $formHelp;?>
		menuType('<?php echo $this->Item['mtype'];?>');
	});

	function menuType(val){
		//alert(val);
		if(val == 'link'){
			$('#trUrl').show();
		}else{
			$('#trUrl').hide();
		}

		if(val == 'module'){
			$('#trModule').show();
			$('#trController').show();
			$('#trAction').show();
			$('#trParam').show();
		}else{
			$('#trModule').hide();
			$('#trController').hide();
			$('#trAction').hide();
			$('#trParam').hide();
		}
	}

	
</script>
<div id="element-box">
	<div class="m">
		<div class="form-table">
            	<fieldset class="admin-fieldset" >
                <legend class="admin-legend"><?php echo $this->translate('Form Detail')?></legend>
            	<table width="100%" border="0">
                	<?php echo $tdForm;?>
                </table>
                </fieldset>    
                    
            </div>
            <div class="clr"></div>
	</div>
</div>
